<template>
	<view>
		<topic-info :info="detail"></topic-info>
		<view 
			class="hot-item py-2 px-2"
			 :class="index !== hotList.length-1 ? 'border-bottom ':''"
			hover-class="bg-hover-light"
			v-for="(item,index) in hotList" :key="index">
			<text class="iconfont icon-xihuan text-main"></text>
			<text class="ml-4">{{item.title}}</text>
		</view>
		<divider />
		<custom-tabbar :tarbarList="tarbarList" @onTabClick="onTabClick"></custom-tabbar>
		<swiper :duration="150">
			<swiper-item v-for="(item,index) in tarbarList" :key="index">
				<scroll-view scroll-y="true" >
					<block v-for="(postItem,postIndex) in detailPostList" :key="postIndex">
						<post-item :item="postItem" :index="postIndex"></post-item>
					</block>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	const demo = [{
			"id": 13,
			"user_id": 13,
			"title": "12132",
			"titlepic": "",
			"content": "12132",
			"sharenum": 0,
			"path": "未知",
			"type": 0,
			"create_time": 1559543916,
			"post_class_id": 1,
			"share_id": 0,
			"isopen": 1,
			"status": 1,
			"ding_count": 0,
			"cai_count": 1,
			"comment_count": 0,
			"user": {
				"id": 13,
				"username": "13838389876",
				"userpic": "http://...png",
				"fens": []
			},
			"images": [],
			"share": null,
			"support": []
		},
		{
			"id": 13,
			"user_id": 13,
			"title": "12132",
			"titlepic": "",
			"content": "12132",
			"sharenum": 0,
			"path": "未知",
			"type": 0,
			"create_time": 1559543916,
			"post_class_id": 1,
			"share_id": 0,
			"isopen": 1,
			"status": 1,
			"ding_count": 0,
			"cai_count": 1,
			"comment_count": 0,
			"user": {
				"id": 13,
				"username": "...",
				"userpic": "http://...png",
				"fens": []
			},
			"images": [],
			"share": null,
			"support": []
		},
		{
			"id": 13,
			"user_id": 13,
			"title": "12132",
			"titlepic": "",
			"content": "12132",
			"sharenum": 0,
			"path": "未知",
			"type": 0,
			"create_time": 1559543916,
			"post_class_id": 1,
			"share_id": 0,
			"isopen": 1,
			"status": 1,
			"ding_count": 0,
			"cai_count": 1,
			"comment_count": 0,
			"user": {
				"id": 13,
				"username": "...",
				"userpic": "http://...png",
				"fens": []
			},
			"images": [],
			"share": null,
			"support": []
		},
		{
			"id": 13,
			"user_id": 13,
			"title": "12132",
			"titlepic": "",
			"content": "12132",
			"sharenum": 0,
			"path": "未知",
			"type": 0,
			"create_time": 1559543916,
			"post_class_id": 1,
			"share_id": 0,
			"isopen": 1,
			"status": 1,
			"ding_count": 0,
			"cai_count": 1,
			"comment_count": 0,
			"user": {
				"id": 13,
				"username": "...",
				"userpic": "http://...png",
				"fens": []
			},
			"images": [],
			"share": null,
			"support": []
		}
	]
	export default {
		data() {
			return {
				tarbarList:['默认','最新'],
				detail:{},
				hotList:[{
					title:"【新人必读】uni-app实战第二季商城类项目开发"
				},{
					title:"【新人必读】uni-app实战第三季仿微信项目开发"
				}],
				detailPostList:[],
			};
		},
		onLoad(options) {
			if(options.info) {
				this.detail = JSON.parse(options.info);
				this.topicId = this.detail.id;
			}
			let list = demo.map(v=> {
				return this.$U.formatCommonList(v)
			})
			this.detailPostList = list;
			this.getDetail();
		},
		methods:{
			getDetail() {
				this.$H.get('/post/'+this.topicId).then(res=> {
					console.log('详情',res)
					if(res.detail) {
						
					}
				})
			},
			onTabClick(item,index) {
				
			}
		}
	}
</script>

<style lang="scss">

</style>
